package com.fy.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;

@WebServlet("*.to")
public class MainServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	@Override
	public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		String path = request.getRequestURI();
		if (path.contains("login.to"))
			request.getRequestDispatcher("/WEB-INF/page/login.jsp").forward(request, response);
		else if (path.contains("index.to"))
			request.getRequestDispatcher("/WEB-INF/page/index.jsp").forward(request, response);
		else if (path.contains("error.to"))
			request.getRequestDispatcher("/WEB-INF/page/error.jsp").forward(request, response);
		else if (path.contains("chat.to"))
			request.getRequestDispatcher("/WEB-INF/page/chat/login.html").forward(request, response);
		else if (path.contains("captcha.to"))
			request.getRequestDispatcher("/WEB-INF/page/captcha.jsp").forward(request, response);
		else if (path.contains("news.to"))
			response.sendRedirect("list.news");
		else if (path.contains("student.to"))
			response.sendRedirect("students?methodName=1");
		else if (path.contains("customer.to"))
			request.getRequestDispatcher("/WEB-INF/page/customer.jsp").forward(request, response);
		else if (path.contains("stock.to"))
			request.getRequestDispatcher("/WEB-INF/page/stock.jsp").forward(request, response);
		else if (path.contains("qrcode.to"))
			request.getRequestDispatcher("/WEB-INF/page/qrcode/createQrcode.jsp").forward(request, response);
		else if (path.contains("vcard.to"))
			request.getRequestDispatcher("/WEB-INF/page/qrcode/vCard.jsp").forward(request, response);
		else if (path.contains("dragUpload.to"))
			request.getRequestDispatcher("/WEB-INF/page/dragUpload.jsp").forward(request, response);
	}
}
